#include <stdio.h>
#include <unistd.h>

int main()
{
	int fd[2] ;
	pipe(fd);
	
	pid_t pid = fork();
	if(pid == 0)
	{
		close(fd[1]);	//close the write end of pipe		
		int i = 0;
		for( ; i < 100  ; ++i)
		{
			read(fd[0] , &i , 4);
//			printf("%d\n",i);
			printf("%d ",i);
			fflush(0);
		}
		close(fd[1]);
		exit(0);
	}
	close(fd[0]);	//close the read end of pipe		
	int i = 0 ;
	for( ; i < 100 ; ++i)
	{
		write(fd[1] , &i , 4);
		usleep(200000);
	}
	close(fd[1]);
	return 0;
}
